Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / feature / map / src / commonTest / kotlin / org / meshtastic / feature / map / kml / KmlGroundOverlayTest.kt

Displaying Raw • Download

feature/map/src/commonTest/kotlin/org/meshtastic/feature/map/kml/KmlGroundOverlayTest.kt renovate/fastlane-2.x-lockfile (056eed64) Text, 4.91 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.map.kml

Tff7b72import T7ee787kotlin.test.Test
Tff7b72import T7ee787kotlin.test.assertEquals
Tff7b72import T7ee787kotlin.test.assertNull
Tff7b72import T7ee787kotlin.test.assertTrue

Tff7b72class T56d364KmlGroundOverlayTest Tb4b4b4{

Tf0883e@Test
Tff7b72fun Td2a8ff`a ground overlay is read with its box and image`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3result Tff7b72=
Te6edf3KmlToGeoJsonTb4b4b4.Te6edf3convertDocumentTb4b4b4(
Ta5d6ff"""
Ta5d6ff <kml><Folder><GroundOverlay>
<name>Tile</name>
<Icon><href>files/tile.png</href></Icon>
<LatLonBox>
<north>50.172</north><south>50.109</south><east>-123.079</east><west>-123.085</west>
</LatLonBox>
</GroundOverlay></Folder></kml>
Ta5d6ff"""Tb4b4b4,
Tb4b4b4)

Tff7b72val Te6edf3overlay Tff7b72= Te6edf3resultTb4b4b4.Te6edf3groundOverlaysTb4b4b4.Te6edf3singleTb4b4b4(Tb4b4b4)
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6ffTileTa5d6ff"Tb4b4b4, Te6edf3overlayTb4b4b4.Te6edf3nameTb4b4b4)
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6fffiles/tile.pngTa5d6ff"Tb4b4b4, Te6edf3overlayTb4b4b4.Te6edf3hrefTb4b4b4)
Te6edf3assertEqualsTb4b4b4(T79c0ff5T79c0ff0.172Tb4b4b4, Te6edf3overlayTb4b4b4.Te6edf3northTb4b4b4)
Te6edf3assertEqualsTb4b4b4(T79c0ff5T79c0ff0.109Tb4b4b4, Te6edf3overlayTb4b4b4.Te6edf3southTb4b4b4)
Te6edf3assertEqualsTb4b4b4(Tff7b72-T79c0ff1T79c0ff2T79c0ff3.079Tb4b4b4, Te6edf3overlayTb4b4b4.Te6edf3eastTb4b4b4)
Te6edf3assertEqualsTb4b4b4(Tff7b72-T79c0ff1T79c0ff2T79c0ff3.085Tb4b4b4, Te6edf3overlayTb4b4b4.Te6edf3westTb4b4b4)
Te6edf3assertEqualsTb4b4b4(T79c0ff0.0Tb4b4b4, Te6edf3overlayTb4b4b4.Te6edf3rotationDegreesTb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`rotation is read when present`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3result Tff7b72=
Te6edf3KmlToGeoJsonTb4b4b4.Te6edf3convertDocumentTb4b4b4(
Ta5d6ff"""
Ta5d6ff <kml><GroundOverlay>
<Icon><href>a.png</href></Icon>
<LatLonBox><north>1</north><south>0</south><east>1</east><west>0</west>
<rotation>-14.5</rotation></LatLonBox>
</GroundOverlay></kml>
Ta5d6ff"""Tb4b4b4,
Tb4b4b4)

Te6edf3assertEqualsTb4b4b4(Tff7b72-T79c0ff1T79c0ff4.5Tb4b4b4, Te6edf3resultTb4b4b4.Te6edf3groundOverlaysTb4b4b4.Te6edf3singleTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3rotationDegreesTb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun `Td2a8ffan Te6edf3overlayTff7b72-Te6edf3only Te6edf3document Tff7b72is Te6edf3not Ta5d6ff"Ta5d6ffnothing mappableTa5d6ff"`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3result Tff7b72=
Te6edf3KmlToGeoJsonTb4b4b4.Te6edf3convertDocumentTb4b4b4(
Ta5d6ff"""
Ta5d6ff <kml><GroundOverlay>
<Icon><href>a.png</href></Icon>
<LatLonBox><north>1</north><south>0</south><east>1</east><west>0</west></LatLonBox>
</GroundOverlay></kml>
Ta5d6ff"""Tb4b4b4,
Tb4b4b4)

Te6edf3assertNullTb4b4b4(Te6edf3resultTb4b4b4.Te6edf3geoJsonTb4b4b4)
Te6edf3assertEqualsTb4b4b4(T79c0ff1Tb4b4b4, Te6edf3resultTb4b4b4.Te6edf3groundOverlaysTb4b4b4.Te6edf3sizeTb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`overlays and placemarks come out of one document together`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3result Tff7b72=
Te6edf3KmlToGeoJsonTb4b4b4.Te6edf3convertDocumentTb4b4b4(
Ta5d6ff"""
Ta5d6ff <kml><Document>
<Placemark><Point><coordinates>1,2</coordinates></Point></Placemark>
<GroundOverlay>
<Icon><href>a.png</href></Icon>
<LatLonBox><north>3</north><south>2</south><east>2</east><west>1</west></LatLonBox>
</GroundOverlay>
</Document></kml>
Ta5d6ff"""Tb4b4b4,
Tb4b4b4)

Te6edf3assertTrueTb4b4b4(Te6edf3resultTb4b4b4.Te6edf3geoJsonTff7b72!!Tb4b4b4.Te6edf3containsTb4b4b4(Ta5d6ff"Ta5d6ff\"Ta5d6ffcoordinatesTa5d6ff\"Ta5d6ff:[1.0,2.0]Ta5d6ff"Tb4b4b4)Tb4b4b4, Te6edf3resultTb4b4b4.Te6edf3geoJsonTb4b4b4)
Te6edf3assertEqualsTb4b4b4(T79c0ff1Tb4b4b4, Te6edf3resultTb4b4b4.Te6edf3groundOverlaysTb4b4b4.Te6edf3sizeTb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`an overlay with no image or no box is dropped`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3result Tff7b72=
Te6edf3KmlToGeoJsonTb4b4b4.Te6edf3convertDocumentTb4b4b4(
Ta5d6ff"""
Ta5d6ff <kml>
<GroundOverlay>
<LatLonBox><north>1</north><south>0</south><east>1</east><west>0</west></LatLonBox>
</GroundOverlay>
<GroundOverlay><Icon><href>a.png</href></Icon></GroundOverlay>
</kml>
Ta5d6ff"""Tb4b4b4,
Tb4b4b4)

Te6edf3assertTrueTb4b4b4(Te6edf3resultTb4b4b4.Te6edf3groundOverlaysTb4b4b4.Te6edf3isEmptyTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`an overlay does not swallow the placemark after it`Tb4b4b4(Tb4b4b4) Tb4b4b4{
T8b949e// The reader tracks element depth; a bug there would eat the rest of the document silently.
Tff7b72val Te6edf3result Tff7b72=
Te6edf3KmlToGeoJsonTb4b4b4.Te6edf3convertDocumentTb4b4b4(
Ta5d6ff"""
Ta5d6ff <kml><Document>
<GroundOverlay>
<Icon><href>a.png</href></Icon>
<LatLonBox><north>1</north><south>0</south><east>1</east><west>0</west></LatLonBox>
</GroundOverlay>
<Placemark><Point><coordinates>5,6</coordinates></Point></Placemark>
</Document></kml>
Ta5d6ff"""Tb4b4b4,
Tb4b4b4)

Te6edf3assertTrueTb4b4b4(Te6edf3resultTb4b4b4.Te6edf3geoJsonTff7b72!!Tb4b4b4.Te6edf3containsTb4b4b4(Ta5d6ff"Ta5d6ff\"Ta5d6ffcoordinatesTa5d6ff\"Ta5d6ff:[5.0,6.0]Ta5d6ff"Tb4b4b4)Tb4b4b4, Te6edf3resultTb4b4b4.Te6edf3geoJsonTb4b4b4)
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.2 - Generated in 0.04s